<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="model.Disciplina" %>
<%@ page import="model.Professor" %>
<%@ page import="model.Materia" %>

<jsp:useBean id="disciplinaEdit" type="model.Disciplina" scope="request" />
<jsp:useBean id="professores" type="java.util.List<model.Professor>" scope="request" />

<script type="text/javascript">
	jQuery(document).ready(function(){
		jQuery('#btnAdicionarProfessor').click(function(){
			jQuery.post('/sigae-ifrn/ComandoAdministradorServlet?comando=adicionarProfessorDisciplina',
			{
				cpfProf : jQuery('#addProfessor option:selected').attr('id'),
				idDisciplina : <%=disciplinaEdit.getIdDisciplina()%>
			},function(data)
			{
				//jQuery('.listProfessorDisciplina tbody').append('<tr><td>'+jQuery('#addProfessor option:selected').text()+'</td><td>Doido</td></tr>');
				jQuery('#editarProfessorDisciplina').empty().load('/sigae-ifrn/ComandoAdministradorServlet?comando=editarDisciplinasTurma&idDisciplina='+<%=disciplinaEdit.getIdDisciplina()%>+'');
				//alert();
				});

			return false;
		});

		jQuery('.removerProfessorDisciplina').click(function(){
			jQuery.post('/sigae-ifrn/ComandoAdministradorServlet?comando=removerProfessorDisciplina',{
					cpfProf : jQuery(this).attr('id'),
					idDisciplina : <%=disciplinaEdit.getIdDisciplina()%>
				},function(data){
				jQuery('#editarProfessorDisciplina').load('/sigae-ifrn/ComandoAdministradorServlet?comando=editarDisciplinasTurma&idDisciplina='+<%=disciplinaEdit.getIdDisciplina()%>+'');
				return false;
			});

		});
	});
</script>

<h2><%=disciplinaEdit.getMateria().getTitulo() %></h2>
							
				<div id="listaProfessores" style="margin-bottom:20px">

				</div>
			<table id="trabalhosDisciplina" class="listProfessorDisciplina">
			<thead>
				<tr>
					<th>Professor</th>
				</tr>
			</thead>
			<tbody>

					<% for(Professor professor : disciplinaEdit.getProfessores()){ %>
					<tr>
						<td><%=professor.getNomeCompleto() %></td>
					</tr>	
					<%} %>
							
			</tbody>
		</table>